<template>
  <el-scrollbar class="dashboard-container">
    <component :is="currentRole" />
  </el-scrollbar>
</template>

<script>
import adminDashboard from './admin'
import assoDashboard from './asso'
import vipDashboard from './vip'
import userDashboard from './user'

export default {
  name: 'Dashboard',
  components: { adminDashboard, assoDashboard, vipDashboard, userDashboard },
  data() {
    return {
      currentRole: ''
    }
  },
  created() {
    this.getRole()
  },
  methods: {
    // 1注册用户2会员3服务机构4协会
    getRole() {
      const userRole = this.$store.state.user.userInfoNew.userRole
      if (userRole === 1) {
        this.currentRole = 'userDashboard'
      } else if (userRole === 2) {
        this.currentRole = 'vipDashboard'
      } else if (userRole === 3) {
        this.currentRole = 'vipDashboard'
      } else if (userRole === 4) {
        this.currentRole = 'assoDashboard'
      } else {
        this.currentRole = 'userDashboard'
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.dashboard-container {
  height: 100%;
  overflow: hidden;
  border-radius: 4px;
  >>> .el-scrollbar__wrap {
    margin-bottom: 0 !important;
    overflow-x: auto;
  }
  >>> .el-scrollbar__bar.is-horizontal > div {
    display: none;
  }
}
</style>
